package nx.simple3d.main;

import nx.simple3d.data.TriangleBase;
import nx.simple3d.data.VectorBase;
import nx.simple3d.data.World;
import nx.simple3d.data.worker.ProjectionWorker;
import nx.simple3d.data.worker.RenderWorker;
import nx.simple3d.gui.Window;

public class Engine {
  private RenderWorker renderWorker;
  private ProjectionWorker projectionWorker;
  private World world;
  private Window window;
  
  public Engine(Core core){
    world = core.getWorld();
    window = core.getWindow();
    
    initialize();
  }
  
  private void initialize(){
    projectionWorker = new ProjectionWorker(world);
    renderWorker = new RenderWorker(window.get3DCanvas());
  }
  
  public void startEngine(){
    VectorBase.getInstance().compile();
    TriangleBase.getInstance().compile();
    new Thread(projectionWorker, "Projection Worker").start();
    new Thread(renderWorker, "Render Worker").start();
  }
  
  public void stopEngine(){
    projectionWorker.stop();
    renderWorker.stop();    
  }
}
